package com.wasion.gydpe.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.wasion.gydpe.dao.ResourceDao;
import com.wasion.gydpe.exception.DataAccessException;
import com.wasion.gydpe.model.Resource;
import com.wasion.gydpe.service.SystemService;

/**
 * 
 * @ClassName: SystemServiceImpl
 * @Description: 系统管理业务实现ServiceImpl
 * @author 高意
 * @date Sep 25, 2012 10:01:31 AM
 * 
 */
@Service
public class SystemServiceImpl implements SystemService {

	// 资源（权限）Dao
	@javax.annotation.Resource
	private ResourceDao resourceDao;

	public List<List<Resource>> queryUndistributeds(Map<String, Object> paramMap)
			throws DataAccessException {

		List<List<Resource>> list = new ArrayList<List<Resource>>();

		List<String> topList = resourceDao.queryTopUndistributeds(paramMap);
		Iterator<String> iterator = topList.iterator();
		while (iterator.hasNext()) {

			String elem = (String) iterator.next();
			paramMap.put("rsId", elem);
			List<Resource> rList = resourceDao.queryUndistributeds(paramMap);

			list.add(rList);
		}

		return list;
	}

	public List<List<Resource>> queryDistributeds(Map<String, Object> paramMap)
			throws DataAccessException {

		List<List<Resource>> list = new ArrayList<List<Resource>>();

		List<String> topList = resourceDao.queryTopDistributeds(paramMap);
		Iterator<String> iterator = topList.iterator();
		while (iterator.hasNext()) {

			String elem = (String) iterator.next();
			paramMap.put("rsId", elem);
			List<Resource> rList = resourceDao.queryDistributeds(paramMap);

			list.add(rList);
		}

		return list;
	}
}
